package com.wbpay.sdk.wrapper;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;

import com.wbpay.sdk.framework.PayResult;
import com.wbpay.sdk.utils.Utils;

/**
 * 易宝支付activity
 */
public class YeePayWrapper extends ActivityWrapper implements DialogInterface.OnDismissListener {

    private ProgressDialog mProgressBar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mProgressBar = ProgressDialog.show(getActivity(), null, "支付中");
        mProgressBar.setCancelable(true);
        mProgressBar.setOnDismissListener(this);
    }

    private void unimplement() {
        String desc = getActivity().getString(Utils.getStringId(getActivity(), "jy_unimplemention"));
        Utils.sendPayResult(getActivity(), PayResult.PAY_FAILURE, desc, getCallbackAction());
    }

    @Override
    public void onDestroy() {
        unimplement();
        super.onDestroy();
    }

    @Override
    public void onDismiss(DialogInterface dialog) {
        getActivity().finish();
    }
}
